require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsTitleHandler = {};
local this = RedDotsTitleHandler;

function RedDotsTitleHandler.init()
    CloseEvent(Config.EventType.ActiveTitle, this.update);
    ListenEvent(Config.EventType.ActiveTitle, this.update);
    CloseEvent(Config.EventType.TitleInfo, this.update);
    ListenEvent(Config.EventType.TitleInfo, this.update);
    return this;
end

function RedDotsTitleHandler.getFlag()
    local flag = Config.RedDotsFlagState.None;
        flag = this.checkTitle();
    return flag;
end

function RedDotsTitleHandler.checkTitle()
    local flag = Config.RedDotsFlagState.None;
    if logicMgr.TitleManager.getIsNewTitle() == 1 then
        flag = Config.RedDotsFlagState.Needful;
    end
    return flag;
end

function RedDotsTitleHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.Title);
end